﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyToDo.Dtos;
using MyToDo.Service;

namespace MyToDo.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LoginController : ControllerBase
    {
        private readonly ILoginService loginService;
        public LoginController(ILoginService loginService)
        {
            this.loginService = loginService;
        }
        [HttpPost]
        public async Task<ApiResponse> Login([FromBody] UserDto user) =>await loginService.LoginAsync(user.Account, user.PassWord);
        [HttpPost]
        public async Task<ApiResponse> Register([FromBody] UserDto user) => await loginService.Register(user);
    }
}
